package com.wego.controller;

import com.wego.bean.TableBean;
import com.wego.common.bean.PageBean;
import com.wego.entity.domain.LoginLog;
import com.wego.entity.query.LoginLogQuery;
import com.wego.service.LoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 登录日志控制器
 *
 * @author Li Chuanwei
 */
@Controller
@RequestMapping("manager/loginLog")
public class LoginLogController {

    @Autowired
    private LoginLogService loginlogService;

    @GetMapping("/list")
    @ResponseBody
    public TableBean list(LoginLogQuery loginlogQuery) {
        System.out.println("loginlogQuery = " + loginlogQuery);

        //构造动态查询条件
        PageBean<LoginLog> loginlogPageBean = loginlogService.selectPage(loginlogQuery);
        System.out.println("loginlogQuery = " + loginlogQuery);
        List<LoginLog> loginlog = loginlogPageBean.getResult();
        Long count = loginlogPageBean.getTotal();
        TableBean tableBean = new TableBean<LoginLog>();
        tableBean.setCode(0);
        tableBean.setMsg("");
        tableBean.setData(loginlog);
        tableBean.setCount(count);
        return tableBean;
    }

}
